<style lang="scss" scoped>
.header {
  width: 100%;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  h4 {
    color: #000;
    font-size: 20px;
  }
}

.menu2 {
  display: flex;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  background-color: #fff;
  font-size: 14px;
}

.tab {
  margin: 5px;
  padding: 5px;
  margin-left: 10px;
  width: 20%;
  background-color: rgb(240, 245, 253);
  border-radius: 50px;
  text-align: center;
}
.active {
  background-color: #00be8c;
  color: #fff;
}
.tab1 {
  display: flex;
  flex-wrap: wrap;
  background-color: #fff;
  font-size: 14px;
}
.list {
  dl {
    display: flex;
    padding: 10px;
    dt {
      width: 50px;
      height: 100px;
      img {
        width: 50px;
        height: 50px;
      }
      margin: 0 10px;
    }
    dd {
      .name {
        font-size: 20px;
        font-weight: 800;
      }
    }
  }
}

.box {
  width: 100vw;
  height: 100%;
  display: flex;
  .left {
    flex: 8;
    height: 100%;
    overflow: auto;
    div {
      width: 100%;
    }
  }
  .right {
    height: 100%;
    overflow: auto;
    flex: 7;
    div {
      display: flex;
      padding-left: 20px;
      width: 100%;
      height: 46px;
      align-items: center;
    }
  }
}
.activeIndex {
  background: #ccc;
}
</style>
<template>

    <div @click="showPopupcity" :model="city" style="font-size: 18px">
      {{ city }} <van-icon name="arrow-down" />
    </div>

  <van-popup v-model:show="showcity" position="top" :style="{ height: '70%' }">
    <div class="box">
      <div class="left">
        <van-sidebar v-model="active">
          <van-sidebar-item
            v-for="(item, index) in areaList.province_list"
            :key="index"
            :title="item"
            @click="getCity(index)"
          >
          </van-sidebar-item>
        </van-sidebar>
      </div>
      <div class="right">
        <div
          v-for="(v, i) in arr1"
          :key="i"
          :class="{ activeIndex: currentIndexcity == i }"
        >
          <div @click="handCity(v, i)">{{ v }}</div>
        </div>
      </div>
    </div>
  </van-popup>






</template>
<script lang="ts" setup>
import { defineProps } from 'vue'
defineProps([])
import type {ListState} from '../../interface'
import { reactive, ref } from 'vue'
import axios from 'axios'
import { areaList } from '@vant/area-data'

// 城市
const showcity = ref(false)
const showPopupcity = () => {
  showcity.value = true
}
const paramsData = reactive({
  pageCode:1,
  pageSize:10,
  lv:'',
  city:'',
  state:'',
  admin:'',
  search:''
})

const currentIndexcity = ref(0)
const city = ref('北京')
const arr1 = ref<string[]>(['北京市'])

const getCity = (v: string) => {
  arr1.value = []

  for (let key in areaList.city_list) {
    if (v.slice(0, 2) == key.slice(0, 2)) {
      arr1.value.push(areaList.city_list[key])
      console.log(v)
    }
  }
}


const handCity = (v: string, i: number) => {
  currentIndex.value = i
  showcity.value = false
  city.value = v
  paramsData.city = v
  console.log(paramsData)
  axios.get('/api/nosocomium/list', { params: paramsData }).then(res => {
    console.log(res)
    doctorState.value = res.data.data
    listData.value = res.data.data
  })
}

const active = ref(0)
const currentIndex = ref(0)
const listData = ref<ListState[]>([])

const doctorState = ref([])

const getList = () => {
  axios
    .get('/api/nosocomium/list', {
      params: paramsData,
    })
    .then(res => {
      const { data } = res.data
      console.log(data)
      listData.value = data
    })
}
getList()


</script>

